import React from 'react';
// event
import emitter from '../../util/events';
// ant
import { Form, Input } from 'antd';
const FormItem = Form.Item;

class Attribute extends React.Component {
    constructor(props){
        super(props);
        this.state = {};
    }

    componentDidMount() {
        emitter.once('submitModal', () => {
            let data = Object.assign(this.props.form.getFieldsValue(), {Delete: true, Type: 'input'});
            emitter.emit('addAttribute', data)
            this.props.form.resetFields();
        })
    }

    render() {
        const { getFieldDecorator } = this.props.form;
        return (
            <div>
                <Form layout="vertical">
                    <FormItem label="Type in a unique detail that buyers might look for">
                        {
                            getFieldDecorator('Name')(
                                <Input />
                            )
                        }
                    </FormItem>

                    <FormItem label="For example, Brand, Material, or Year">
                        {
                            getFieldDecorator('Value')(
                                <Input />
                            )
                        }
                    </FormItem>

                    <FormItem label="For example, Ty, Plastic or 2007"></FormItem>
                </Form>
            </div>
        )
    }
}

export default Form.create()(Attribute)